<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>网站基本设置</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="Author" content="larry" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="Shortcut Icon" href="/favicon.ico" />
    <link rel="stylesheet" type="text/css" href="/static/admin/common/layui/css/layui.css" media="all">
    <link rel="stylesheet" type="text/css" href="/static/admin/backstage/css/base.css" media="all">
    <link rel="stylesheet" type="text/css" href="/static/admin/common/css/animate.css" media="all">
    <link rel="stylesheet" type="text/css" href="/static/admin/backstage/css/admin.css" media="all">
</head>
<body>
<div class="layui-fluid">
    <div class="larry-container larryms-admin">
        <div class="layui-row layui-col-space20">
            <div class="layui-col-xs12 animated fadeInRightBig">
                <section class="larry-panel">
                    <div class="larryms-page-header">
                        <span class="tit">网站配置</span>
                    </div>
                    <div class="larryms-page-body">
                        <form class="layui-form" enctype="multipart/form-data">
                            <div class="layui-form-item">
                                <label class="layui-form-label">网站标题</label>
                                <div class="layui-input-block">
                                    <input type="text" name="config[web_site_title]" value="{$config.web_site_title}" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item layui-form-text">
                                <label class="layui-form-label">网站描述</label>
                                <div class="layui-input-block">
                                    <textarea name="config[web_site_description]" placeholder="请输入网站描述" class="layui-textarea">{$config.web_site_description}</textarea>
                                </div>
                            </div>
                            <div class="layui-form-item layui-form-text">
                                <label class="layui-form-label">网站关键字</label>
                                <div class="layui-input-block">
                                    <textarea name="config[web_site_keyword]" placeholder="请输入网站关键字" class="layui-textarea">{$config.web_site_keyword}</textarea>
                                </div>
                            </div>
                            <div class="layui-form-item layui-form-text">
                                <label class="layui-form-label">LOGO上传</label>
                                <div class="layui-input-block">
                                    <div>
                                        <input type="text" name="config[web_site_logo]" id="logo" value="{$config.web_site_logo}" class="layui-input">
                                    </div>
                                    <p style="margin:6px;auto;color: #737879;">logo上传物理地址：/public/uploads/logo</p>
                                    <p style="margin:6px;auto;color: #999;font-style: italic">图片大小不能超过10M</p>
                                    <div class="layui-upload-drag" id="test10">
                                        <i class="layui-icon"></i>
                                        <p>点击上传，或将文件拖拽到此处</p>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">网站备案号</label>
                                <div class="layui-input-block">
                                    <input type="text" name="config[web_site_icp]" value="{$config.web_site_icp}" required  lay-verify="required" placeholder="请输入网站备案号" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item layui-form-text">
                                <label class="layui-form-label">统计代码</label>
                                <div class="layui-input-block">
                                    <textarea name="config[web_site_cnzz]" placeholder="请输入统计代码" class="layui-textarea">{$config.web_site_cnzz}</textarea>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">版权信息</label>
                                <div class="layui-input-block">
                                    <input type="text" name="config[web_site_copy]" value="{$config.web_site_copy}" required  lay-verify="required" placeholder="请输入版权信息" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">站点状态</label>
                                <div class="layui-input-block">
                                    <input type="checkbox" name="config[web_site_close]" lay-skin="switch" lay-text="开启|关闭" {eq name="$config.web_site_close" value="1" } checked {/eq}>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button class="layui-btn" lay-submit lay-filter="config_edit">立即提交</button>
                                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </section>
            </div>
        </div>
    </div>
</div>
<!-- 加载js文件-->
<script type="text/javascript" src="/static/admin/common/layui/layui.js"></script>
<script>
    layui.use(['form','upload','jquery','layer'], function(){
        var $ = layui.jquery
            ,upload = layui.upload;
        var form = layui.form;
        //拖拽上传
        upload.render({
            elem: '#test10'
            ,url: '/admin/config/uploadLogo'
            ,done: function(res, index, upload){
                //假设code=0代表上传成功
                //console.log(res);
                if(res.code == '1'){
                    layer.msg(res.msg, {icon: 6});
                    $('#logo').val(res.name);
                }else{
                    layer.msg(res.msg, {icon: 5});
                }
            }
        });
        //ajax表单提交
        form.on('submit(config_edit)', function(data){
            $.ajax({
                type:"POST",
                url:"{:url('admin/config/configEdit')}",
                dataType:"JSON",
                data:data.field,
                success:function(res){
                    if(res.code == '1'){
                        layer.msg(res.msg, {icon: 6});
                        //console.log(data.code);
                    }else if(res.code == '-1'){
                        layer.msg(res.msg, {icon: 5});
                    }else if(res.code == '-2'){
                        layer.msg(res.msg, {icon: 5});
                    }else if(res.code == '-3'){
                        layer.msg(res.msg, {icon: 5});
                    }
                }
            });
            return false;
        });
    });
</script>
</body>
</html>